package com.six.controller;

import com.six.pojo.Identity;
import com.six.result.Result;
import com.six.result.ResultUtils;
import com.six.service.IdentityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/identity")
@Api(tags = "y身份证")
@CrossOrigin
@ResponseBody
public class IdentityController {
    @Autowired
    private IdentityService identityService;

    @GetMapping("/{id}")
    @ApiOperation(value = "根据用户id查询身份证")
    public Result findByAdminId(@PathVariable("id")Long id){
        Identity identity = identityService.getById(id);
        return ResultUtils.buildSuccess(identity);
    }

    @PostMapping("/add")
    @ApiOperation(value = "添加身份证信息")
    public Result add(@RequestBody Identity identity){
        identityService.save(identity);
        return ResultUtils.buildSuccess();
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改身份信息")
    public Result update(@RequestBody Identity identity){
        identityService.updateById(identity);
        return ResultUtils.buildSuccess();
    }
}
